﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatterns
{
    /// <summary>
    /// 接口类，客户端类
    /// </summary>
    public interface ITarget
    {
        string GetRequest();
    }

    /// <summary>
    /// 被适配者     例如遗留老代码，开源模块等
    /// </summary>
    public class Adaptee
    {
        public string GetSpecificRequest()
        {
            return "特殊的请求  遗留的老代码";
        }
    }

    /// <summary>
    /// 适配器
    /// </summary>
    public class Adapter : ITarget
    {
        private readonly Adaptee _adaptee;

        public Adapter(Adaptee adaptee)
        {
            this._adaptee = adaptee;
        }

        /// <summary>
        /// 显示实现的接口类
        /// 在这里可以调用遗留老代码的方法。
        /// </summary>
        /// <returns></returns>
        public string GetRequest()
        {
            return "我正在调用：" + _adaptee.GetSpecificRequest();
        }
    }

    class AdaptPattern
    {
    }
}
